#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N];
int m, n;
typedef long long LL;

int find(int t)
{
    int l = 1, r = m;
    while(l < r)
    {
        int mid = l + (r - l) / 2;
        if(a[mid] >= t) r = mid;
        else l = mid + 1;
    }

    return l;
}

int main()
{
    cin >> m >> n;
    for(int i = 1;i <= m;i++) cin >> a[i];

    sort(a + 1, a + m + 1);
    LL ret = 0;
    a[0] = -1e7;
    for(int i = 1;i <= n;i++)
    {
        LL b; cin >> b;
        int pos = find(b);
        ret += min(abs(a[pos] - b), abs(a[pos - 1] - b));
    }

    cout << ret << endl;
    return 0;
}